﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Umbrella.Whs.SharePoint;

namespace Umbrella.Whs.WhsAddin.Wizards.SharePointInstallation
{
    internal class InstallStepCreateUmbrellaWebsite : IInstallStep
    {
        private IEnumerable<int> _languageLCIDs;

        public string Title
        {
            get { return Resources.txtCreatingUmbrellaWebsite; }
        }

        public int Weight
        {
            get { return 200; }
        }

        public void PerformInstall()
        {
            var wm = new WebsiteManager();

            // determine website language
            var currentLCID = Thread.CurrentThread.CurrentUICulture.LCID;

            if (!_languageLCIDs.Contains(currentLCID))
                currentLCID = InstallationManager.RootLanguageLCID;

            // create website and site collection
            wm.CreateUmbrellaWebsite(currentLCID);
        }

        public InstallStepCreateUmbrellaWebsite(IEnumerable<int> languageLCIDs)
        {
            if (languageLCIDs == null)
                throw new ArgumentNullException("languageLCIDs");

            _languageLCIDs = languageLCIDs;
        }
    }
}
